package jwlee.testxml;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import org.dom4j.Document;
import org.dom4j.Element;

public class SchoolParser {
	private static final Logger logger = Logger.getLogger(Dom4jUtils.class.getName());

	public static void main(String[] args) {
		String fileName = "src/jwlee/testxml/school.xml";
		Document doc = Dom4jUtils.read(fileName);
		String elementPath = "/school/class[@name='class2']/student[@no='002']";
		Element e = Dom4jUtils.getElementByXpath(doc, elementPath);
		StudentVO vo = new StudentVO();
		Map map = new HashMap();
		map.put("gradeMath", "./grade/math");
		map.put("gradeChinese", "./grade/Chinese");
		Dom4jUtils.parseElement2VO(e, vo, map);
		logger.info(vo.toString());
		
//		Element ele = Dom4jUtils.getElementByXpath(doc, "/school/class[@name='class2']/student/grade");
//		logger.info(ele.getName() + ":" + ele.getTextTrim());
	}

}
